#pragma once

#include "usart_interface.h"

#define GIMBAL_DATA_SEND_FLOAT_NUM          ((uint8_t)0)
#define GIMBAL_DATA_SEND_SHORT_NUM          ((uint8_t)5)//pitch,yaw,frction*2,supply_bullet
#define GIMBAL_DATA_SEND_CHAR_NUM          ((uint8_t)0)
#define GIMBAL_DATA_RECEIVE_FLOAT_NUM       ((uint8_t)13)//gimbal_pitch,gimbal_pitch_speed,gimbal_yaw,gimbal_yaw_speed,yaw_angle,,yaw_speed,gimbal_pitch_encoder,gimbal_yaw_encoder,3508*2,2006*2(angle,speed)
#define GIMBAL_DATA_RECEIVE_CHAR_NUM       ((uint8_t)2)//yaw_gimbal_safe_flag，supply_safe_flag;
#define GIMBAL_DATA_RECEIVE_SHORT_NUM       ((uint8_t)4)//sys_monitor
#define GIMBAL_DATA_SEND_SIZE            ((uint8_t)4 + 4 * GIMBAL_DATA_SEND_FLOAT_NUM + \
                                        2 * GIMBAL_DATA_SEND_SHORT_NUM + GIMBAL_DATA_SEND_CHAR_NUM)
#define GIMBAL_DATA_RECEIVE_SIZE            ((uint8_t)4 + 4 * GIMBAL_DATA_RECEIVE_FLOAT_NUM + \
                                        2 * GIMBAL_DATA_RECEIVE_SHORT_NUM + GIMBAL_DATA_RECEIVE_CHAR_NUM)

//TODO: 【云台】云台类
class Gimbal {
public:
    #pragma pack(1)
    struct GimbalDataSendFrame {
        unsigned char m_head[2];
        int16_t m_sdata[GIMBAL_DATA_SEND_SHORT_NUM]; //pitch,yaw,friction*2,supply_bullet
        unsigned char m_cdata[GIMBAL_DATA_SEND_CHAR_NUM]; 
        unsigned char m_tail[2];
    };//主控发给云控的数据
    struct GimbalDataReceiveFrame {
        unsigned char m_head[2];
        float m_fdata[GIMBAL_DATA_RECEIVE_FLOAT_NUM];
        int16_t m_sdata[GIMBAL_DATA_RECEIVE_SHORT_NUM];
        unsigned char m_cdata[GIMBAL_DATA_RECEIVE_CHAR_NUM]; 
        unsigned char m_tail[2];
    };//主控从云控接收的数据
    #pragma pack()

	unsigned char m_data_send_size;
	GimbalDataSendFrame m_data_send_frame;
	GimbalDataReceiveFrame m_data_receive_frame;
    Usart* usart_gimbal;

    Gimbal() {
		m_data_send_size = GIMBAL_DATA_SEND_SIZE;

        m_data_send_frame.m_head[0] = 0x55;
        m_data_send_frame.m_head[1] = 0x00;

        m_data_receive_frame.m_head[0]  = 0x55;
        m_data_receive_frame.m_head[1]  = 0x00;
        m_data_receive_frame.m_tail[0]  = 0x00;
        m_data_receive_frame.m_tail[1]  = 0xAA;

        usart_gimbal = new Usart();
	};

    void SetUartHandle(USART_TypeDef* USARTx);
    void SendData(void);

private:
};